/* eslint-disable @typescript-eslint/no-var-requires */
const { app, BrowserWindow, Menu } = require('electron');
const path = require('path/posix');

const createWindow = () => {
  //Menu.setApplicationMenu(null);
  const mainWindow = new BrowserWindow({
    height: 600,
    width: 800,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
      preload: path.join(__dirname, 'preload.js'),
    },
    maximizable: false,
    resizable: false,
  });
  if (app.isPackaged) {
    mainWindow.loadFile('dist/index.html');
    mainWindow.send;
  } else {
    mainWindow.loadURL('http://localhost:13344');
    mainWindow.webContents.openDevTools();
  }
  mainWindow.webContents.on('did-finish-load', () => {
    mainWindow.webContents.send('s', app.getPath('exe'));
  });
};

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // On OS X it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});
